package com.controller;

import com.entity.Category;
import com.service.CategoryService;
import com.until.Result;
import com.vo.Page;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author :hcy
 * @date:
 * @description:
 */
@RestController
@RequestMapping("cate")
public class CategoryController extends BaseController{
    @Resource
    private CategoryService categoryService;
    @GetMapping("listAll")
    public Result listAll(){
       return success(categoryService.listAll());
    }
    @PostMapping("list")
    public Result list(@RequestBody Page<Category> page){
        return success(categoryService.list(page));
    }
    @GetMapping("lists")
    public Result lists(){
        return success(categoryService.lists());
    }

    @GetMapping("queryById")
    public Result queryById(Integer categoryId){
        return success(categoryService.queryById(categoryId));
    }
    @PostMapping("insert")
    public Result insert(@RequestBody Category category){
        return success(categoryService.insert(category));
    }
    @PutMapping ("update")
    public Result update(@RequestBody Category category){
        return success(categoryService.update(category));
    }
    @DeleteMapping("deleteById")
    public Result deleteById(Integer categoryId){
        return success(categoryService.deleteById(categoryId));
    }
}
